package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:张熳
 * Date:2025-08-24
 * Time:17:51
 */
//多态
//向上转型和 向下转型(instanceof) + 重写

public class Dog extends Animal{
    public Dog(String name, int age) {
        super(name, age);
    }

    public void bark(){
        System.out.println(this.name + " 正在汪汪叫...");
    }
    @Override  //注解，表示当前修饰的这个方法是被重写的
    public void eat(){
        System.out.println(this.name + " 吃骨头~");
    }
    //返回值类型可以不一样，但是必须构成父子关系
    public Dog sleep(){
        System.out.println(this.name + " 小狗在睡觉~");
        return null;
    }
}
